@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono&family=Fira+Code&display=swap');

/**
 * 1. CSS变量定义
 */
:root {
  /* 字体系统 */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-code: 'OperatorMonoSSmLig Nerd Font', 'Cascadia Code PL', 'FantasqueSansMono Nerd Font', 'operator mono',
    JetBrainsMono, 'Fira code Retina', 'Fira code', Consolas, Monaco, 'Hannotate SC', monospace, -apple-system;

  /* 颜色系统 - 亮色模式 */
  --text-primary: #252525;
  --text-secondary: #606060;
  --text-tertiary: #767676;
  --bg-primary: #ffffff;
  --bg-secondary: #f7f9fb;
  --bg-tertiary: #efefef;
  --accent-color: var(--accent-color-light);
  --accent-color-assistant: var(--accent-color-light-assistant);
  --accent-color-hover: var(--accent-color-light-hover);
  --accent-color-alpha: var(--accent-color-light-alpha);
  --tw-gradient-from-position: ;
  --tw-gradient-to-position: ;
  --tw-gradient-via-position: ;
  --tw-gradient-from: var(--fallback-a,oklch(var(--a)/0)) var(--tw-gradient-from-position);
  --tw-gradient-to: var(--fallback-a,oklch(var(--a)/0)) var(--tw-gradient-to-position);
  --spotlight-color: oklch(var(--a)/0.12);
  --underline-bg: var(--tw-gradient-from),var(--fallback-a,oklch(var(--a)/0.7)) var(--tw-gradient-via-position),var(--tw-gradient-to);
  --error-color: #e53935;
  --success-color: #43a047;
  --border-color: rgba(0, 0, 0, 0.06);

  /* 尺寸和间距 */
  --header-height: 60px;
  --max-width: 1120px;
  --content-width: 860px;
  --sidebar-width: 260px;

  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 6px 16px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 8px 24px rgba(0, 0, 0, 0.12);
  --card-shadow: 0 8px 30px rgba(81, 131, 245, 0.08);

  /* 圆角 */
  --radius-small: 8px;
  --radius-medium: 12px;
  --radius-large: 16px;
  --radius-full: 9999px;

  /* 过渡效果 */
  --transition-fast: 0.1s;
  --transition: 0.2s;
  --transition-slow: 0.3s;
  --transition-normal: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --bezier-bounce: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --bezier-accelerate: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --bezier-smooth: cubic-bezier(0.4, 0, 0.2, 1);

  /* 断点 */
  --mobile: 768px;
  --tablet: 992px;
  --desktop: 1200px;
}

/**
 * 暗色主题变量
 */
[data-theme='dark'] {
  --text-primary: #f0f0f0;
  --text-secondary: #a0a0a0;
  --text-tertiary: #888;
  --bg-primary: #121212;
  --bg-secondary: #181818;
  --bg-tertiary: #333;
  --border-color: rgba(255, 255, 255, 0.08);
  --card-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  --accent-color: var(--accent-color-dark);
  --accent-color-assistant: var(--accent-color-dark-assistant);
  --accent-color-hover: var(--accent-color-dark-hover,rgba(81, 131, 245, 0.2));
  --accent-color-alpha: var(--accent-color-dark-alpha, rgba(81, 131, 245, 0.1));
}

/**
 * 主题过渡效果
 */
.theme-transition {
  transition: color 0.3s ease, background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/**
 * 全局重置和基础样式
 */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  font-family: var(--font-sans);
  /* background-color: var(--bg-primary); */
  color: var(--text-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 15px;
  line-height: 1.6;
  font-weight: 400;
  scroll-behavior: smooth;
  letter-spacing: -0.01em;
  height: auto;
  overflow: visible;
}

#root {
  min-height: 100vh;
  width: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent-color);
  text-decoration: none;
  transition: var(--transition-normal);
}

button {
  cursor: pointer;
  border: none;
  outline: none;
  background: none;
  font-family: var(--font-sans);
  font-size: 0.95rem;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 1rem;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

h1 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.75rem;
  letter-spacing: -0.02em;
}

h3 {
  font-size: 1.35rem;
}

p {
  line-height: 1.7;
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

input,
textarea,
select {
  font-family: inherit;
}

code,
pre,
.code {
  font-family: var(--font-code);
}

::selection {
  background: rgba(81, 131, 245, 0.2);
  color: var(--accent-color);
}

/**
 * 导航和Header样式
 */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--header-height);
  transition: all 0.3s var(--bezier-smooth);
  border-radius: 0 0 24px 24px;
  background: transparent;
}

.underline {
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 70px;
  height: 2px;
  background: linear-gradient(to right,var(--underline-bg));
  opacity: 1;
  transition: all 0.2s ease;
}

.header.scrolled {
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 0 #0000, 0 0 #0000, 0 1px 2px 0 rgb(0 0 0/0.05);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 6px 32px 0 rgba(81, 131, 245, 0.1);
}

[data-theme='dark'] .header.scrolled {
  background: rgba(18, 18, 18, 0.92);
  backdrop-filter: blur(20px);
  box-shadow: 0 6px 20px 0 rgba(81, 131, 245, 0.14);
}

.nav-card {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 28px;
  padding: 0.3rem 1.25rem;
  height: 44px;
  transition: all 0.3s var(--bezier-smooth);
  position: relative;
  z-index: 60;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 8px 24px 0 rgba(81, 131, 245, 0.2);
  backdrop-filter: blur(16px);
  margin-left: auto;
}

[data-theme='dark'] .nav-card {
  background: rgba(30, 30, 30, 0.98);
  box-shadow: 0 8px 24px 0 rgba(81, 131, 245, 0.2);
}

.header.scrolled .nav-card {
  background: transparent;
  box-shadow: none;
  border: none;
  backdrop-filter: none;
}

[data-theme='dark'] .header.scrolled .nav-card {
  background: transparent;
  box-shadow: none;
  border: none;
  backdrop-filter: none;
}

/* 导航链接悬停效果 */
.nav-link-hover {
  position: relative;
  z-index: 1;
}

.nav-link-hover .bg-effect {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 140%;
  height: 100%;
  background: radial-gradient(
    ellipse 70% 100% at 50% 50%,
    transparent 0%,
    var(--spotlight-color) 20%,
    transparent 100%
  );
  z-index: -1;
  border-radius: 10px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.nav-link-hover:hover .bg-effect {
  opacity: 1;
}

.nav-link-hover:hover {
  color: var(--text-primary);
}

/* 移动端导航样式 */
.mobile-nav {
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-primary);
  z-index: 95;
  display: flex;
  flex-direction: column;
  padding-top: 2rem;
  gap: 1.5rem;
  border-radius: 0 0 24px 24px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateY(-100%);
  overflow-y: auto;
}

.mobile-nav.open {
  transform: translateY(0);
}

.mobile-overlay {
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 90;
}

/**
 * 卡片和容器样式
 */
.card {
  background-color: var(--bg-primary);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: transform 0.2s var(--bezier-accelerate), box-shadow 0.2s var(--bezier-accelerate);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

[data-theme='dark'] .card {
  background-color: var(--bg-secondary);
  box-shadow: var(--shadow-md);
}

.card-container {
  perspective: 1000px;
}

.card-face {
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  position: absolute;
  width: 100%;
  height: 100%;
}

.card-back {
  transform: rotateY(180deg);
}

/**
 * 按钮样式
 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.2rem;
  font-weight: 500;
  border-radius: 8px;
  transition: all 0.2s var(--bezier-accelerate);
  border: none;
  background-color: var(--accent-color);
  color: white;
}

.btn:hover {
  background-color: var(--accent-color-hover);
  transform: translateY(-2px);
}

.btn-secondary {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background-color: var(--bg-tertiary);
}

/**
 * 动画和过渡
 */
.page-transition-enter {
  opacity: 0;
  transform: translateY(10px);
}

.page-transition-enter-active {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.3s, transform 0.3s;
}

.page-transition-exit {
  opacity: 1;
  transform: translateY(0);
}

.page-transition-exit-active {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s;
}

.fade-in {
  animation: fadeIn 0.4s var(--bezier-accelerate) forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/**
 * 10. 滚动条样式
 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: rgba(81, 131, 245, 0.2);
  border-radius: 10px;
  transition: all 0.3s ease;
  opacity: 0;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(81, 131, 245, 0.6);
}

/* 只在滚动时显示滚动条 */
*:hover::-webkit-scrollbar-thumb {
  opacity: 1;
}

/* 火狐浏览器滚动条 */
* {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

*:hover {
  scrollbar-color: rgba(81, 131, 245, 0.2) transparent;
}

/* 深色模式滚动条 */
[data-theme='dark'] ::-webkit-scrollbar-thumb {
  background: rgba(81, 131, 245, 0.3);
}

[data-theme='dark'] ::-webkit-scrollbar-thumb:hover {
  background: rgba(81, 131, 245, 0.7);
}

[data-theme='dark'] *:hover {
  scrollbar-color: rgba(81, 131, 245, 0.3) transparent;
}

@media (max-width: 768px) {
  .nav-card {
    display: none;
  }

  .container,
  .content-container {
    padding: 0 1rem;
  }
}

/* 添加文章标题高亮效果 */
@keyframes highlightHeading {
  0% {
    background-color: rgba(81, 131, 245, 0);
  }
  30% {
    background-color: rgba(81, 131, 245, 0.15);
  }
  70% {
    background-color: rgba(81, 131, 245, 0.15);
  }
  100% {
    background-color: rgba(81, 131, 245, 0);
  }
}

.highlight-heading {
  animation: highlightHeading 2s ease forwards;
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  margin-left: -0.5rem;
}
